package com.gxa.modules.app.hospitalization.persional.controller;

import com.gxa.common.utils.Result;
import com.gxa.modules.app.hospitalization.persional.dto.DayPriceDto;
import com.gxa.modules.app.hospitalization.persional.dto.DayTotalPriceDto;
import com.gxa.modules.app.hospitalization.persional.dto.DefaultPatient;
import com.gxa.modules.app.hospitalization.persional.service.DayListService;
import com.gxa.modules.model.entity.fee.Patient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static javax.print.attribute.standard.MediaPrintableArea.MM;

@Api(tags = "住院日清单")
@RestController
@RequestMapping("/daylist")
public class DayListController {
    @Autowired
    private DayListService dayListService;

//    @ApiOperation("查询默认的住院日清单")
////    @GetMapping("/querydefault")
////    public Result selectDayList(){
////        Patient patient = dayListService.select();
////        DefaultPatient defaultPatient = new DefaultPatient();
////        defaultPatient.setID_num(patient.getCardNum());
////        defaultPatient.setName(patient.getName());
////        defaultPatient.setType(patient.getRelationType());
////        return new Result<DefaultPatient>().ok(defaultPatient);
////    }

    @ApiOperation("通过时间和id查询日消费金额")
    @GetMapping("/queryprice")
    public Result selectPrice(@RequestParam Date dateTime , @RequestParam Integer id){

        List<DayPriceDto> dayPriceDto = dayListService.selectByTime(dateTime, id);
        DayTotalPriceDto dayTotalPriceDto = dayListService.selectTotalPrice(dateTime, id);
        Map map = new HashMap();
        map.put(1,dayTotalPriceDto);
        map.put(2,dayPriceDto);
        map.get(dayPriceDto);
        map.get(dayTotalPriceDto);
        System.out.println(dayPriceDto);
        System.out.println(dayTotalPriceDto);
        return new Result<Map>().ok(map);
    }
    @InitBinder
    protected void initBinder(WebDataBinder binder) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
    }

}
